<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background: #ccc;
        }
    </style>
    <script>
        function sendAjax() {
            var xhr = new XMLHttpRequest()
            xhr.onreadystatechange = function () {
                if (xhr.readyState == 4 && xhr.status == 200) {
                    var data = xhr.responseText
                    // console.log(typeof data)
                    console.log(data)
                    var obj = JSON.parse(data)
                    if(obj.status == 1){
                        document.getElementById('content').innerText = obj.data.name
                    }else{
                        document.getElementById('content').innerText = obj.message
                    }
                }
            }
            xhr.open('post', 'ajax')
            xhr.send()
        }
    </script>
</head>
<body>
<input type="button" value="发送Ajax请求" onclick="sendAjax()">
<hr>

<div id="content">

</div>
</body>
</html>